package com.test.ant.payment.handler;

public class Counter {
    private int cursor;
    private int all;

    public Counter(int all) {
        this.all = all;
        this.cursor = -1;
    }

    public int getCursorIndex() {
        synchronized (this) {
            this.cursor++;
            if (this.cursor == this.all) {
                // 如果已经没有了，就返回-1
                return -1;
            }
            return this.cursor;
        }
    }
}
